#include <stdlib.h>
#include <stdio.h>

#include "LinkQueue.h"


struct LinkQueue
{
    DLlist list;
};

LQueue * InitLQueue()
{
    LQueue *q = (LQueue *)malloc(sizeof(LQueue));
    if(q == NULL)
        return NULL;
    InitDLlist(&q->list);
    return q;
}

void QPush(LQueue * q, ElementType element)
{
    InsertDLlistTial(&q->list,element);
}

void QPop(LQueue * q)
{
    RemoveByIndex(&q->list,0,NULL);
}

ElementType* GetQFront(LQueue * q)
{
    return FindByIndex(&q->list,0);
}

bool IsQueueEmpty(LQueue * q)
{
    return q->list.len == 0;
}

int GetQueueLen(LQueue * q)
{
    return q->list.len;
}

void ClearLQueue(LQueue * q, void(* clearPtr)(ElementType))
{
    ClearDLlist(&q->list,clearPtr);
}

void TravelLQueue(LQueue * q, void(* funcPtr)(ElementType))
{
    TravelDLlist(&q->list,funcPtr);
}